home *** CD-ROM | disk | FTP | other *** search
- ;void write_right(strg,col,row,color);
- ; unsigned char *strg,col,row,color;
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _write_right
- _write_right proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- pushf ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov cl,_snow_protect ;get _snow_protect
- push ds ;save Turbo's DS
- mov ax,_video_buffer ;fetch Videobuffer
- mov es,ax ;ES pts to buffer
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- inc bp ;add 2 to BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov si,[bp+4] ;near case
- L00: sub bx,bx ;
- mov bl,[bp+8] ;Row
- dec bx ;count from zero
- mov byte ptr[bp+8],cl ;save _snow_protect
- sub cx,cx ;
- mov cl,[bp+6] ;Col
- dec cx ;count from zero
- mov ax,160 ;bytes per row
- mul bl ;row offset
- shl cx,1 ;dble cols for attributes
- add ax,cx ;offset to start position
- mov di,ax ;ES:DI pts to start
- sub cx,cx ;clear CX
- cmp byte ptr[si],0 ;test for null string
- je L5 ;
- L000: inc si ;move SI to end of string
- inc cx ;inc string length counter
- cmp byte ptr[si],0 ;test for end of string
- jne L000 ;loop
- dec si ;pull back pointer
- std ;reverse direction
- mov ah,[bp+10] ;get screen attribute
- L1: lodsb ;get a char from Strg
- cmp byte ptr[bp+8],0 ;protect against snow?
- je L4 ;jump if not
- mov bx,ax ;save char-attri in BX
- mov dx,3dah ;status byte address
- L2: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L2 ;loop till 0
- cli ;disable interrupts
- L3: in al,dx ;get status byte
- test al,1 ;test bit
- jz L3 ;loop till 1, then write
- mov ax,bx ;return char/attri to AX
- L4: stosw ;write the char and color
- loop L1 ;loop till finished
- L5: sti ;reenable interrupts
- pop ds ;
- popf ;
- pop si ;
- pop di ;
- pop bp ;
- cld ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _write_right endp
- _TEXT ENDS
- END